package com.jackchong.base;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import androidx.annotation.Nullable;



/**
 * 作者: jack(黄冲)
 * 邮箱: 907755845@qq.com
 * create on 2018/1/9 17:11
 */

public abstract class BaseSerivce extends Service {

    protected Context mContext;

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
        AppManager.getInstance().addService(this);

    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        init(intent, flags, startId);

        return START_STICKY;

    }

    protected abstract void init(Intent intent, int flags, int startId);


    @Override
    public void onDestroy() {
        super.onDestroy();
        AppManager.getInstance().removeService(this);
    }
}
